package mole.tools;

public class dev
{
	public static String geneSqlParam(String s)
	{
		String r = "";
		String[] sa = s.split(java.util.regex.Pattern.quote(","), -1);
		 for (String item : sa)
		 {
			 if (r.equals(""))
			 {
				 r = "'@" + item + "'";
			 }
			 else
			 {
				 r = r + ",'@" + item + "'";
			 }
		 }
		 return r;
	}

	public static String geneSqlParamForUpdate(String s)
	{
		String r = "";
		String[] sa = s.split(java.util.regex.Pattern.quote(","), -1);
		for (String item : sa)
		{
			if (r.equals(""))
			{
				r = item + "='@" + item + "'"; //   gys='@gys'
			}
			else
			{
				r = r + "," + item + "='@" + item + "'";
			}

		}
		return r;
	}

	public static void geneSqlParamReplace(String s)
	{
		String r = "";
		String[] sa = s.split(java.util.regex.Pattern.quote(","), -1);
		for (String item : sa)
		{
			String s2 = "  sql = sql.Replace(\"@" + item + "\"," + item + " );   ";
			System.out.println(s2);
		}




	}

	public static void geneCreatTAbleSql(String s) //for mysql
	{
		 String r = "";
		String[] sa = s.split(java.util.regex.Pattern.quote(","), -1);
		 for (String item : sa)
		 {
			String s2 = " `" + item + "` varchar(50) DEFAULT NULL,";
			  System.out.print(s2);
		 }
	//     return r;



	}


	public static String geneCreatTAbleSqlForSql(String s, String taable, String id) //for sql
	{
		String r = "";
		String[] sa = s.split(java.util.regex.Pattern.quote(","), -1);
		for (String item : sa)
		{
			String col = item.trim();
			String s2 = " `" + col + "` [varchar](100) NULL,";
			r = r + s2;
		}


		String pre = " CREATE TABLE " + taable + "(	[id] [int] IDENTITY(1,1) NOT NULL,";
		String last = ") ON [PRIMARY]";
		r = MOLE.global.trimx(r, ",");
	   r = pre + r + last;
		 return r;
	}

	 public static String geneAddColumnSql(String s, String taable) //for sql
	 {
		  String r = "";


		String[] sa = s.split(java.util.regex.Pattern.quote(","), -1);
		for (String item : sa)
		{
			r = r + "   alter table " + taable + " add " + item + " varchar(100) null  ;";


		}



		 return r;
	 }




}